var e = require, t = module, n = exports;

Object.defineProperty(n, "__esModule", {
    value: !0
});

var o = e("LoadManager"), i = function() {
    function e() {
        this.spritePool = new cc.NodePool(), this.skeletonPool = new cc.NodePool(), this.labelPool = new cc.NodePool();
    }
    return e.getInstance = function() {
        return this._instance || (this._instance = new e()), this._instance;
    }, e.prototype.getSpriteNode = function() {}, e.prototype.getSprite = function(l) {
        var i = this;
        return new Promise(function(e, t) {
            var n = i.getSpriteByPool(l.node);
            o.default.getInstance().loadSpriteFrame({
                url: l.url,
                sprite: n,
                success: function() {
                    n instanceof cc.Sprite ? e(n) : t("res not sprite");
                },
                fail: function() {
                    t("loadRes sprite fail:" + l.url);
                }
            });
        });
    }, e.prototype.getSpriteByPool = function(e) {
        return 0 < this.spritePool.size() ? this.spritePool.get().getComponent(cc.Sprite) : e ? cc.instantiate(e).getComponent(cc.Sprite) : new cc.Node().addComponent(cc.Sprite);
    }, e.prototype.putSprite = function(e) {
        var t = e.getComponent(cc.Sprite);
        e.zIndex = 0, e.angle = 0, e.scale = 1, e.setPosition(cc.Vec2.ZERO), t ? (t.spriteFrame = null, 
        this.spritePool.put(e)) : e.destroy();
    }, e.prototype.getSkeleton = function(e) {
        var i = this;
        return new Promise(function(t, n) {
            var l = i.getSkeletonByPool();
            o.default.getInstance().loadRes({
                url: e.url,
                type: sp.SkeletonData
            }).then(function(e) {
                l instanceof sp.Skeleton && e instanceof sp.SkeletonData ? (l.skeletonData = e, 
                t(l)) : n("res not skeleton");
            }).catch(function() {
                n("loadRes skeleton fail:" + e.url);
            });
        });
    }, e.prototype.getSkeletonByPool = function() {
        if (0 < this.skeletonPool.size()) return this.skeletonPool.get().getComponent(sp.Skeleton);
        var e = new cc.Node().addComponent(sp.Skeleton);
        return e.setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE), e.enableBatch = !0, 
        e;
    }, e.prototype.putSkeleton = function(e) {
        var t = e.getComponent(sp.Skeleton);
        e.zIndex = 0, e.angle = 0, e.scale = 1, e.setPosition(cc.Vec2.ZERO), t ? (t.setCompleteListener(null), 
        t.setEndListener(null), t.setToSetupPose(),t.premultipliedAlpha = false, t.skeletonData = null, this.skeletonPool.put(e)) : e.destroy();
    }, e.prototype.getLabel = function() {
        var e = this;
        return new Promise(function(t) {
            0 < e.labelPool.size() ? t(e.labelPool.get().getComponent(cc.Label)) : o.default.getInstance().loadRes({
                url: "prefab/label",
                type: cc.Prefab
            }).then(function(e) {
                t(cc.instantiate(e).getComponent(cc.Label));
            });
        });
    }, e.prototype.putLabel = function(e) {
        cc.Tween.stopAllByTarget(e);
        var t = e.getComponent(cc.Label);
        e.zIndex = 0, e.angle = 0, e.opacity = 255, e.scale = 1, e.color = cc.Color.WHITE, 
        e.setPosition(cc.Vec2.ZERO), t ? this.labelPool.put(e) : e.destroy();
    }, e._instance = null, e;
}();

n.default = i;